<template>
  <div class="container">
    <movie-item v-for="item of dif" :key="item._id" :item="item"></movie-item>
  </div>
</template>

<script>
import MovieItem from "../../components/Movie/MovieItem.vue";
import HomeHttp from "../../model/HomeHttp";
export default {
  components: { MovieItem },
  data() {
    return {
      dif: [],
    };
  },
  mounted() {
    console.log(this.$route.query);
  },
  async activated() {
    var { title } = this.$route.query;
    // var fn = this.handleHttp(title);
    // console.log(title);
    var res = await HomeHttp.getMovie(title);
    console.log(res);
    res.data.res.forEach((item) => {
      var { rating, raiting } = item;
      item.star = rating
        ? HomeHttp.handleStar(rating)
        : HomeHttp.handleStar(raiting);
    });
    this.dif = res.data.res;
  },
  // methods: {
  //   handleHttp(title) {
  //     if (title == "tops") {
  //       return "getTopMovie";
  //     } else if (title == "hots") {
  //       return "getHotMovie";
  //     } else if (title == "comings") {
  //       return "getComingMovie";
  //     }
  //   },
  // },
};
</script>

<style>
</style>